<?php
	require("user_settings.php");
	$cname="";$passwd="";

	if(isset($_GET['cname']))
		$cname=htmlspecialchars($_GET['cname']);
	if(isset($_GET['passwd']))
		$passwd=htmlspecialchars($_GET['passwd']);

	if(strlen($cname) == 0) {
		echo "<html><body>";
		echo "<script lang=javascript> document.location.href=(\"index_m.php?err='使用者是空的'\");</script>";
		echo "</html></body>";
		exit ;
	}

	$uname= getCompUserMapping($cname);
    if($uname== "") {
		echo "<html><body>";
		echo "<script lang=javascript> document.location.href=(\"index_m.php?err='公司代碼 $cname 不存在'\");</script>";
		echo "</html></body>";
		
	}
	else {
		
		$users = getUser($uname);
		if($users['rpass'] != $passwd) {
			echo "<html><body>";
			echo "<script lang=javascript> document.location.href=(\"index_m.php?err='密碼錯誤'\");</script>";
			echo "</body></html>";
		}
		else {
			session_save_path("./.php_session");
			session_start();
			$_SESSION["login_m"] = true;
			$_SESSION["id_m"] = "$uname";
			echo "<html><body>";
			echo "<script lang=javascript> document.location.href=(\"offer_m.php\");</script>";
			echo "</body></html>";

			
		}
	}

	
?>
